# RUN: llvm-mc -triple hexagon -disassemble < %s | FileCheck %s
# Hexagon Programmer's Reference Manual 11.5 LD

# Load doubleword
0x90 0xff 0xd5 0x3a
# CHECK: r17:16 = memd(r21+r31<<#3)
0xb0 0xc2 0xc0 0x49
# CHECK: r17:16 = memd(gp+#168)
0x02 0x40 0x00 0x00 0x10 0xc5 0xc0 0x49
# CHECK: r17:16 = memd(##168)
0xd0 0xc0 0xd5 0x91
# CHECK: r17:16 = memd(r21+#48)
0xb0 0xe0 0xd5 0x99
# CHECK: r17:16 = memd(r21++#40:circ(m1))
0x10 0xe2 0xd5 0x99
# CHECK: r17:16 = memd(r21++I:circ(m1))
0x00 0x40 0x00 0x00 0x70 0xd7 0xd5 0x9b
# CHECK: r17:16 = memd(r21=##31)
0xb0 0xc0 0xd5 0x9b
# CHECK: r17:16 = memd(r21++#40)
0x10 0xe0 0xd5 0x9d
# CHECK: r17:16 = memd(r21++m1)
0x10 0xe0 0xd5 0x9f
# CHECK: r17:16 = memd(r21++m1:brev)

# Load doubleword conditionally
0xf0 0xff 0xd5 0x30
# CHECK: if (p3) r17:16 = memd(r21+r31<<#3)
0xf0 0xff 0xd5 0x31
# CHECK: if (!p3) r17:16 = memd(r21+r31<<#3)
0x03 0x40 0x45 0x85 0xf0 0xff 0xd5 0x32
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17:16 = memd(r21+r31<<#3)
0x03 0x40 0x45 0x85 0xf0 0xff 0xd5 0x33
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17:16 = memd(r21+r31<<#3)
0x70 0xd8 0xd5 0x41
# CHECK: if (p3) r17:16 = memd(r21+#24)
0x03 0x40 0x45 0x85 0x70 0xd8 0xd5 0x43
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17:16 = memd(r21+#24)
0x70 0xd8 0xd5 0x45
# CHECK: if (!p3) r17:16 = memd(r21+#24)
0x03 0x40 0x45 0x85 0x70 0xd8 0xd5 0x47
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17:16 = memd(r21+#24)
0xb0 0xe6 0xd5 0x9b
# CHECK: if (p3) r17:16 = memd(r21++#40)
0xb0 0xee 0xd5 0x9b
# CHECK: if (!p3) r17:16 = memd(r21++#40)
0x03 0x40 0x45 0x85 0xb0 0xf6 0xd5 0x9b
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17:16 = memd(r21++#40)
0x03 0x40 0x45 0x85 0xb0 0xfe 0xd5 0x9b
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17:16 = memd(r21++#40)

# Load byte
0x91 0xff 0x15 0x3a
# CHECK: r17 = memb(r21+r31<<#3)
0xb1 0xc2 0x00 0x49
# CHECK: r17 = memb(gp+#21)
0x00 0x40 0x00 0x00 0xb1 0xc2 0x00 0x49
# CHECK: r17 = memb(##21)
0xf1 0xc3 0x15 0x91
# CHECK: r17 = memb(r21+#31)
0xb1 0xe0 0x15 0x99
# CHECK: r17 = memb(r21++#5:circ(m1))
0x11 0xe2 0x15 0x99
# CHECK: r17 = memb(r21++I:circ(m1))
0x00 0x40 0x00 0x00 0x71 0xd7 0x15 0x9b
# CHECK: r17 = memb(r21=##31)
0xb1 0xc0 0x15 0x9b
# CHECK: r17 = memb(r21++#5)
0x11 0xe0 0x15 0x9d
# CHECK: r17 = memb(r21++m1)
0x11 0xe0 0x15 0x9f
# CHECK: r17 = memb(r21++m1:brev)

# Load byte conditionally
0xf1 0xff 0x15 0x30
# CHECK: if (p3) r17 = memb(r21+r31<<#3)
0xf1 0xff 0x15 0x31
# CHECK: if (!p3) r17 = memb(r21+r31<<#3)
0x03 0x40 0x45 0x85 0xf1 0xff 0x15 0x32
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17 = memb(r21+r31<<#3)
0x03 0x40 0x45 0x85 0xf1 0xff 0x15 0x33
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17 = memb(r21+r31<<#3)
0x91 0xdd 0x15 0x41
# CHECK: if (p3) r17 = memb(r21+#44)
0x03 0x40 0x45 0x85 0x91 0xdd 0x15 0x43
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17 = memb(r21+#44)
0x91 0xdd 0x15 0x45
# CHECK: if (!p3) r17 = memb(r21+#44)
0x03 0x40 0x45 0x85 0x91 0xdd 0x15 0x47
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17 = memb(r21+#44)
0xb1 0xe6 0x15 0x9b
# CHECK: if (p3) r17 = memb(r21++#5)
0xb1 0xee 0x15 0x9b
# CHECK: if (!p3) r17 = memb(r21++#5)
0x03 0x40 0x45 0x85 0xb1 0xf6 0x15 0x9b
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17 = memb(r21++#5)
0x03 0x40 0x45 0x85 0xb1 0xfe 0x15 0x9b
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17 = memb(r21++#5)

# Load byte into shifted vector
0xf0 0xc3 0x95 0x90
# CHECK: r17:16 = memb_fifo(r21+#31)
0xb0 0xe0 0x95 0x98
# CHECK: r17:16 = memb_fifo(r21++#5:circ(m1))
0x10 0xe2 0x95 0x98
# CHECK: r17:16 = memb_fifo(r21++I:circ(m1))

# Load half into shifted vector
0xf0 0xc3 0x55 0x90
# CHECK: r17:16 = memh_fifo(r21+#62)
0xb0 0xe0 0x55 0x98
# CHECK: r17:16 = memh_fifo(r21++#10:circ(m1))
0x10 0xe2 0x55 0x98
# CHECK: r17:16 = memh_fifo(r21++I:circ(m1))

# Load halfword
0x91 0xff 0x55 0x3a
# CHECK: r17 = memh(r21+r31<<#3)
0xb1 0xc2 0x40 0x49
# CHECK: r17 = memh(gp+#42)
0x00 0x40 0x00 0x00 0x51 0xc5 0x40 0x49
# CHECK: r17 = memh(##42)
0xf1 0xc3 0x55 0x91
# CHECK: r17 = memh(r21+#62)
0xb1 0xe0 0x55 0x99
# CHECK: r17 = memh(r21++#10:circ(m1))
0x11 0xe2 0x55 0x99
# CHECK: r17 = memh(r21++I:circ(m1))
0x00 0x40 0x00 0x00 0x71 0xd7 0x55 0x9b
# CHECK: r17 = memh(r21=##31)
0xb1 0xc0 0x55 0x9b
# CHECK: r17 = memh(r21++#10)
0x11 0xe0 0x55 0x9d
# CHECK: r17 = memh(r21++m1)
0x11 0xe0 0x55 0x9f
# CHECK: r17 = memh(r21++m1:brev)

# Load halfword conditionally
0xf1 0xff 0x55 0x30
# CHECK: if (p3) r17 = memh(r21+r31<<#3)
0xf1 0xff 0x55 0x31
# CHECK: if (!p3) r17 = memh(r21+r31<<#3)
0x03 0x40 0x45 0x85 0xf1 0xff 0x55 0x32
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17 = memh(r21+r31<<#3)
0x03 0x40 0x45 0x85 0xf1 0xff 0x55 0x33
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17 = memh(r21+r31<<#3)
0xb1 0xe6 0x55 0x9b
# CHECK: if (p3) r17 = memh(r21++#10)
0xb1 0xee 0x55 0x9b
# CHECK: if (!p3) r17 = memh(r21++#10)
0x03 0x40 0x45 0x85 0xb1 0xf6 0x55 0x9b
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17 = memh(r21++#10)
0x03 0x40 0x45 0x85 0xb1 0xfe 0x55 0x9b
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17 = memh(r21++#10)
0xf1 0xdb 0x55 0x41
# CHECK: if (p3) r17 = memh(r21+#62)
0xf1 0xdb 0x55 0x45
# CHECK: if (!p3) r17 = memh(r21+#62)
0x03 0x40 0x45 0x85 0xf1 0xdb 0x55 0x43
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17 = memh(r21+#62)
0x03 0x40 0x45 0x85 0xf1 0xdb 0x55 0x47
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17 = memh(r21+#62)

# Load unsigned byte
0x91 0xff 0x35 0x3a
# CHECK: r17 = memub(r21+r31<<#3)
0xb1 0xc2 0x20 0x49
# CHECK: r17 = memub(gp+#21)
0x00 0x40 0x00 0x00 0xb1 0xc2 0x20 0x49
# CHECK: r17 = memub(##21)
0xf1 0xc3 0x35 0x91
# CHECK: r17 = memub(r21+#31)
0xb1 0xe0 0x35 0x99
# CHECK: r17 = memub(r21++#5:circ(m1))
0x11 0xe2 0x35 0x99
# CHECK: r17 = memub(r21++I:circ(m1))
0x00 0x40 0x00 0x00 0x71 0xd7 0x35 0x9b
# CHECK: r17 = memub(r21=##31)
0xb1 0xc0 0x35 0x9b
# CHECK: r17 = memub(r21++#5)
0x11 0xe0 0x35 0x9d
# CHECK: r17 = memub(r21++m1)
0x11 0xe0 0x35 0x9f
# CHECK: r17 = memub(r21++m1:brev)

# Load unsigned byte conditionally
0xf1 0xff 0x35 0x30
# CHECK: if (p3) r17 = memub(r21+r31<<#3)
0xf1 0xff 0x35 0x31
# CHECK: if (!p3) r17 = memub(r21+r31<<#3)
0x03 0x40 0x45 0x85 0xf1 0xff 0x35 0x32
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17 = memub(r21+r31<<#3)
0x03 0x40 0x45 0x85 0xf1 0xff 0x35 0x33
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17 = memub(r21+r31<<#3)
0xf1 0xdb 0x35 0x41
# CHECK: if (p3) r17 = memub(r21+#31)
0x03 0x40 0x45 0x85 0xf1 0xdb 0x35 0x43
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17 = memub(r21+#31)
0xf1 0xdb 0x35 0x45
# CHECK: if (!p3) r17 = memub(r21+#31)
0x03 0x40 0x45 0x85 0xf1 0xdb 0x35 0x47
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17 = memub(r21+#31)
0xb1 0xe6 0x35 0x9b
# CHECK: if (p3) r17 = memub(r21++#5)
0xb1 0xee 0x35 0x9b
# CHECK: if (!p3) r17 = memub(r21++#5)
0x03 0x40 0x45 0x85 0xb1 0xf6 0x35 0x9b
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17 = memub(r21++#5)
0x03 0x40 0x45 0x85 0xb1 0xfe 0x35 0x9b
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17 = memub(r21++#5)

# Load unsigned halfword
0x91 0xff 0x75 0x3a
# CHECK: r17 = memuh(r21+r31<<#3)
0xb1 0xc2 0x60 0x49
# CHECK: r17 = memuh(gp+#42)
0x00 0x40 0x00 0x00 0x51 0xc5 0x60 0x49
# CHECK: r17 = memuh(##42)
0xb1 0xc2 0x75 0x91
# CHECK: r17 = memuh(r21+#42)
0xb1 0xe0 0x75 0x99
# CHECK: r17 = memuh(r21++#10:circ(m1))
0x11 0xe2 0x75 0x99
# CHECK: r17 = memuh(r21++I:circ(m1))
0x00 0x40 0x00 0x00 0x71 0xd7 0x75 0x9b
# CHECK: r17 = memuh(r21=##31)
0xb1 0xc0 0x75 0x9b
# CHECK: r17 = memuh(r21++#10)
0x11 0xe0 0x75 0x9d
# CHECK: r17 = memuh(r21++m1)
0x11 0xe0 0x75 0x9f
# CHECK: r17 = memuh(r21++m1:brev)

# Load unsigned halfword conditionally
0xf1 0xff 0x75 0x30
# CHECK: if (p3) r17 = memuh(r21+r31<<#3)
0xf1 0xff 0x75 0x31
# CHECK: if (!p3) r17 = memuh(r21+r31<<#3)
0x03 0x40 0x45 0x85 0xf1 0xff 0x75 0x32
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17 = memuh(r21+r31<<#3)
0x03 0x40 0x45 0x85 0xf1 0xff 0x75 0x33
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17 = memuh(r21+r31<<#3)
0xb1 0xda 0x75 0x41
# CHECK: if (p3) r17 = memuh(r21+#42)
0xb1 0xda 0x75 0x45
# CHECK: if (!p3) r17 = memuh(r21+#42)
0x03 0x40 0x45 0x85 0xb1 0xda 0x75 0x43
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17 = memuh(r21+#42)
0x03 0x40 0x45 0x85 0xb1 0xda 0x75 0x47
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17 = memuh(r21+#42)
0xb1 0xe6 0x75 0x9b
# CHECK: if (p3) r17 = memuh(r21++#10)
0xb1 0xee 0x75 0x9b
# CHECK: if (!p3) r17 = memuh(r21++#10)
0x03 0x40 0x45 0x85 0xb1 0xf6 0x75 0x9b
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17 = memuh(r21++#10)
0x03 0x40 0x45 0x85 0xb1 0xfe 0x75 0x9b
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17 = memuh(r21++#10)

# Load word
0x91 0xff 0x95 0x3a
# CHECK: r17 = memw(r21+r31<<#3)
0xb1 0xc2 0x80 0x49
# CHECK: r17 = memw(gp+#84)
0x01 0x40 0x00 0x00 0x91 0xc2 0x80 0x49
# CHECK: r17 = memw(##84)
0xb1 0xc2 0x95 0x91
# CHECK: r17 = memw(r21+#84)
0xb1 0xe0 0x95 0x99
# CHECK: r17 = memw(r21++#20:circ(m1))
0x11 0xe2 0x95 0x99
# CHECK: r17 = memw(r21++I:circ(m1))
0x00 0x40 0x00 0x00 0x71 0xd7 0x95 0x9b
# CHECK: r17 = memw(r21=##31)
0xb1 0xc0 0x95 0x9b
# CHECK: r17 = memw(r21++#20)
0x11 0xe0 0x95 0x9d
# CHECK: r17 = memw(r21++m1)
0x11 0xe0 0x95 0x9f
# CHECK: r17 = memw(r21++m1:brev)

# Load word conditionally
0xf1 0xff 0x95 0x30
# CHECK: if (p3) r17 = memw(r21+r31<<#3)
0xf1 0xff 0x95 0x31
# CHECK: if (!p3) r17 = memw(r21+r31<<#3)
0x03 0x40 0x45 0x85 0xf1 0xff 0x95 0x32
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17 = memw(r21+r31<<#3)
0x03 0x40 0x45 0x85 0xf1 0xff 0x95 0x33
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17 = memw(r21+r31<<#3)
0xb1 0xda 0x95 0x41
# CHECK: if (p3) r17 = memw(r21+#84)
0xb1 0xda 0x95 0x45
# CHECK: if (!p3) r17 = memw(r21+#84)
0x03 0x40 0x45 0x85 0xb1 0xda 0x95 0x43
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17 = memw(r21+#84)
0x03 0x40 0x45 0x85 0xb1 0xda 0x95 0x47
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17 = memw(r21+#84)
0xb1 0xe6 0x95 0x9b
# CHECK: if (p3) r17 = memw(r21++#20)
0xb1 0xee 0x95 0x9b
# CHECK: if (!p3) r17 = memw(r21++#20)
0x03 0x40 0x45 0x85 0xb1 0xf6 0x95 0x9b
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) r17 = memw(r21++#20)
0x03 0x40 0x45 0x85 0xb1 0xfe 0x95 0x9b
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) r17 = memw(r21++#20)

# Deallocate stack frame
0x1e 0xc0 0x1e 0x90
# CHECK: deallocframe

# Deallocate stack frame and return
0x1e 0xc0 0x1e 0x96
# CHECK: dealloc_return
0x03 0x40 0x45 0x85 0x1e 0xcb 0x1e 0x96
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) dealloc_return:nt
0x1e 0xd3 0x1e 0x96
# CHECK: if (p3) dealloc_return
0x03 0x40 0x45 0x85 0x1e 0xdb 0x1e 0x96
# CHECK: p3 = r5
# CHECK-NEXT: if (p3.new) dealloc_return:t
0x03 0x40 0x45 0x85 0x1e 0xeb 0x1e 0x96
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) dealloc_return:nt
0x1e 0xf3 0x1e 0x96
# CHECK: if (!p3) dealloc_return
0x03 0x40 0x45 0x85 0x1e 0xfb 0x1e 0x96
# CHECK: p3 = r5
# CHECK-NEXT: if (!p3.new) dealloc_return:t

# Load and unpack bytes to halfwords
0xf1 0xc3 0x35 0x90
# CHECK: r17 = membh(r21+#62)
0xf1 0xc3 0x75 0x90
# CHECK: r17 = memubh(r21+#62)
0xf0 0xc3 0xb5 0x90
# CHECK: r17:16 = memubh(r21+#124)
0xf0 0xc3 0xf5 0x90
# CHECK: r17:16 = membh(r21+#124)
0xb1 0xe0 0x35 0x98
# CHECK: r17 = membh(r21++#10:circ(m1))
0x11 0xe2 0x35 0x98
# CHECK: r17 = membh(r21++I:circ(m1))
0xb1 0xe0 0x75 0x98
# CHECK: r17 = memubh(r21++#10:circ(m1))
0x11 0xe2 0x75 0x98
# CHECK: r17 = memubh(r21++I:circ(m1))
0xb0 0xe0 0xf5 0x98
# CHECK: r17:16 = membh(r21++#20:circ(m1))
0x10 0xe2 0xf5 0x98
# CHECK: r17:16 = membh(r21++I:circ(m1))
0xb0 0xe0 0xb5 0x98
# CHECK: r17:16 = memubh(r21++#20:circ(m1))
0x10 0xe2 0xb5 0x98
# CHECK: r17:16 = memubh(r21++I:circ(m1))
0x00 0x40 0x00 0x00 0x71 0xd7 0x35 0x9a
# CHECK: r17 = membh(r21=##31)
0xb1 0xc0 0x35 0x9a
# CHECK: r17 = membh(r21++#10)
0x00 0x40 0x00 0x00 0x71 0xd7 0x75 0x9a
# CHECK: r17 = memubh(r21=##31)
0xb1 0xc0 0x75 0x9a
# CHECK: r17 = memubh(r21++#10)
0x00 0x40 0x00 0x00 0x70 0xd7 0xb5 0x9a
# CHECK: r17:16 = memubh(r21=##31)
0xb0 0xc0 0xb5 0x9a
# CHECK: r17:16 = memubh(r21++#20)
0x00 0x40 0x00 0x00 0x70 0xd7 0xf5 0x9a
# CHECK: r17:16 = membh(r21=##31)
0xb0 0xc0 0xf5 0x9a
# CHECK: r17:16 = membh(r21++#20)
0x00 0x40 0x00 0x00 0xf1 0xf7 0x35 0x9c
# CHECK: r17 = membh(r21<<#3+##31)
0x11 0xe0 0x35 0x9c
# CHECK: r17 = membh(r21++m1)
0x00 0x40 0x00 0x00 0xf1 0xf7 0x75 0x9c
# CHECK: r17 = memubh(r21<<#3+##31)
0x11 0xe0 0x75 0x9c
# CHECK: r17 = memubh(r21++m1)
0x00 0x40 0x00 0x00 0xf0 0xf7 0xf5 0x9c
# CHECK: r17:16 = membh(r21<<#3+##31)
0x10 0xe0 0xf5 0x9c
# CHECK: r17:16 = membh(r21++m1)
0x00 0x40 0x00 0x00 0xf0 0xf7 0xb5 0x9c
# CHECK: r17:16 = memubh(r21<<#3+##31)
0x11 0xe0 0x35 0x9c
# CHECK: r17 = membh(r21++m1)
0x11 0xe0 0x75 0x9c
# CHECK: r17 = memubh(r21++m1)
0x10 0xe0 0xf5 0x9c
# CHECK: r17:16 = membh(r21++m1)
0x10 0xe0 0xb5 0x9c
# CHECK: r17:16 = memubh(r21++m1)
0x11 0xe0 0x35 0x9e
# CHECK: r17 = membh(r21++m1:brev)
0x11 0xe0 0x75 0x9e
# CHECK: r17 = memubh(r21++m1:brev)
0x10 0xe0 0xb5 0x9e
# CHECK: r17:16 = memubh(r21++m1:brev)
0x10 0xe0 0xf5 0x9e
# CHECK: r17:16 = membh(r21++m1:brev)
